package main

import (
	"github.com/urfave/cli"
	"log"
	config2 "onedriver-storage/config"
	server2 "onedriver-storage/server"
	"os"
)

var (
	app = cli.NewApp()
)

func init() {
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "c",
			Usage:       "config file",
			Value:       "./config.yaml",
			Destination: nil,
		},
	}
}

func main() {
	app.Action = run
	if err := app.Run(os.Args); err != nil {
		log.Fatal(err)
	}
}

func run(ctx *cli.Context) error {

	config, err := config2.FromFile(ctx.String("c"))
	if err != nil {
		return err
	}

	server := server2.NewServer(config)
	server.StartSYNC()
	return nil
}
